import { ref } from 'vue'
import { defineStore } from 'pinia'
import { userLogin } from '@/apis/User'

export const useUserStore = defineStore('user', () => {
  const userInfo = ref({})

  const login = async (account, password) => {
    let res = await userLogin(account, password)
    userInfo.value = res.result
    console.log(res.result)
  }
  //清除userInfon
  const layout = () => {
    userInfo.value = {}
  }
  return {
    userInfo,
    login,
    layout
  }
}, {
  persist: true  // 启用持久化存储
})
